package com.gulimall.gulimallproduct.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class MyredissionConfig {
    /**
     * 所有对redissipn的操作都是通过RedissionClient对象
     *
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redission() throws IOException {
        //1创建配置
        Config config=new Config();
        config.useSingleServer().setAddress("redis://localhost:6379");
        //根据config创建redissonclient实例
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
